package com.two.lbms.hjx.controller;

import com.two.lbms.base.BaseController;
import com.two.lbms.hjx.dto.BookDTO;
import com.two.lbms.hjx.dto.IllegalDTO;
import com.two.lbms.hjx.service.BookInfoService;
import com.two.lbms.hjx.service.IllegalService;
import com.two.lbms.vo.BookInfo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author hjx
 * @version V1.0
 * @Date 2023/7/31 10:04
 */
@Controller
@Slf4j
public class HjxPageController extends BaseController {

    @Resource
    private IllegalService illegalService;
    @Resource
    private BookInfoService bookInfoService;

    @RequestMapping("toIllegalPage")
    public String toIllegalPage() {
        return "hjx/illegal";
    }
    @RequestMapping("illegal/toIllegalAddPage")
    public String toIllegalAddPage() {
        return "hjx/add";
    }
    @RequestMapping("illegal/toIllegalEditPage")
    public String toIllegalEditPage(Integer id, HttpServletRequest request) {
        IllegalDTO illegalDTO = illegalService.selectByIllegalId(id);
        log.info("修改违规信息的前端赋值 : {}", illegalDTO);
        request.setAttribute("illegal", illegalDTO);
        return "hjx/edit";
    }
    @RequestMapping("toBookPage")
    public String toBookPage() {
        return "book/book";
    }
    @RequestMapping("book/toBookAddPage")
    public String toBookAddPage() {
        return "book/add";
    }
    @RequestMapping("book/toBookEditPage")
    public String toBookEditPage(Integer id, HttpServletRequest request) {
        BookDTO bookInfo = bookInfoService.selectByBookId(id);
        log.info("修改图书的前端信息 : {}",bookInfo);
        request.setAttribute("book", bookInfo);
        return "book/edit";
    }
    @RequestMapping("toRenewPage")
    public String toRenewPage() {
        return "hjx/renew";
    }


}
